<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Alternation and repetition</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parle.regex.unicodecharclass.html">« Unicode character classes</a></li>
      <li style="float: right;"><a href="parle.regex.anchors.html">Anchors »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="parle.pattern.matching.html">Pattern matching</a></li>
    <li>Alternation and repetition</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="parle.regex.alternation" class="section">
  <h2 class="title">Alternation and repetition</h2>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Alternation and repetition</strong></caption>
    
     <thead>
      <tr>
       <th>Sequence</th><th>Greedy</th><th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>...|...</td><td>-</td><td>Try subpatterns in alternation.</td>
      </tr>

      <tr>
       <td>*</td><td>yes</td><td>Match 0 or more times.</td>
      </tr>

      <tr>
       <td>+</td><td>yes</td><td>Match 1 or more times.</td>
      </tr>

      <tr>
       <td>?</td><td>yes</td><td>Match 0 or 1 times.</td>
      </tr>

      <tr>
       <td>{n}</td><td>no</td><td>Match exactly n times.</td>
      </tr>

      <tr>
       <td>{n,}</td><td>yes</td><td>Match at least n times.</td>
      </tr>

      <tr>
       <td>{n,m}</td><td>yes</td><td>Match at least n times but no more than m times.</td>
      </tr>

      <tr>
       <td>*?</td><td>no</td><td>Match 0 or more times.</td>
      </tr>

      <tr>
       <td>+?</td><td>no</td><td>Match 1 or more times.</td>
      </tr>

      <tr>
       <td>??</td><td>no</td><td>Match 0 or 1 times.</td>
      </tr>

      <tr>
       <td>{n,}?</td><td>no</td><td>Match at least n times.</td>
      </tr>

      <tr>
       <td>{n,m}?</td><td>no</td><td>Match at least n times but no more than m times.</td>
      </tr>

      <tr>
       <td>{MACRO}</td><td>-</td><td>Include the regex MACRO in the current regex.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div></div></div></body></html>